package com.zjhb.common.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;

public interface BaseDao {
	/**
	 * <b>function:</b>增加一个entity对象，返回是否添加成功
	 * 
	 * @createDate 2016-11-25 下午02:44:34
	 * @author ending
	 *            对象类型
	 * @param entity
	 *            实体类
	 * @return boolean true/false
	 * @throws Exception
	 */
	public <T> void saveOrUpdate(T entity);
	
	public Long  getCount(Criteria crt);
	
	public <T> void save(T entity);

	
	public int executeData(String hql);

	public <T> List<T> findByHql(String hql);

	
	public int executeBySql(String sql);

	
	public <T> List<T> findBySql(String sql);

	
	public <T> boolean update(T entity);

	
	public int editNumHql(String hql,Object[] objs);

	
	public <T> boolean delete(T entity);
	
	public <T> boolean delete(Class<T> clazz,Serializable id);

	public boolean remove(String hql);

	public <T> T getById(Class<T> clazz, Serializable id);

	public <T> T getByHql(String hql);

	// 查询list
	public <T> List<T> getList(Class<T> clazz);

	public <T> List<T> getList(String hql, Object[] obj, int first, int page);

	public <T> List<T> getList(String hql, int first, int page);

	public <T> Page<T> getList(Criteria criteria, int first, int maxResults);

	public <T> List<T> getList(String hql);

	public Session getSession();

	public Criteria getCriteria(Class<?> clazz);

	 <T> void save(List<T> list);

}
